package com.tucy.logistics.modules.system.menu.controller;

import com.tucy.logistics.common.dto.first.WorkspaceDto;
import com.tucy.logistics.common.entity.user.SystemMenu;
import com.tucy.logistics.common.result.Result;
import com.tucy.logistics.modules.system.menu.service.SystemMenuService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * author: tcy
 * createDate: 2023/9/7
 * description: 菜单服务
 */
@Api(tags = "菜单服务")
@RestController
@RequestMapping("/menu")
public class MenuController {

    @Autowired
    SystemMenuService systemMenuService;

    @ApiOperation(value = "查询全部菜单")
    @GetMapping("/queryAllMenus")
    public Result<List<SystemMenu>> queryAllMenus(){
        return Result.success(systemMenuService.queryAllMenus());
    }

    @ApiOperation(value = "保存修改菜单")
    @PostMapping("/saveUpdateMenus")
    public Result<Boolean> saveUpdateMenus(@RequestBody List<SystemMenu> menus){
        return Result.success(systemMenuService.saveUpdateMenus(menus));
    }

    @ApiOperation(value = "首页数据")
    @GetMapping("/workspace")
    public Result<WorkspaceDto> workspace (){
        return Result.success(systemMenuService.workspace());
    }

}
